home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume10 / pccurses14 / part02 < prev    next >
Encoding:
Text File  |  1990-01-19  |  51.6 KB  |  1,614 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v10i016: PCcurses v.1.4 part 2 of 7
  3. from: bl@infovox.se (Bj|rn Larsson)
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 10, Issue 16
  7. Submitted-by: bl@infovox.se (Bj|rn Larsson)
  8. Archive-name: pccurses14/part02
  9.  
  10. # ----------------------------- cut here -----------------------------
  11. #! /bin/sh
  12. # This is a shell archive. Remove anything before the `cut' line,
  13. # then unpack by saving it into a file and typing `sh file'. The
  14. # archive ends by exit(0), so don't worry about trailing junk.
  15. #       (This is archive 2 in a series of 7).
  16. # Contents:
  17. #   attrib.c
  18. #   border.c
  19. #   boxes.c
  20. #   chardel.c
  21. #   clrtobot.c
  22. #   clrtoeol.c
  23. #   curspriv.h
  24. #   linedel.c
  25. #   lineins.c
  26. #   options.c
  27. #   refresh.c
  28. #   setmode.c
  29. #   setterm.c
  30. # Wrapped by USER@MS-DOS --- Sun Jan 14 14:02:26 1990
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. if test -f attrib.c -a "${1}" != "-c" ; then 
  33.   echo Will not over-write existing file \"attrib.c\"
  34. else
  35. echo Extracting - \"attrib.c\"
  36. sed "s/^X//" >attrib.c <<'END_OF_attrib.c'
  37. X/****************************************************************/
  38. X/* Character attribute routines of the PCcurses package        */
  39. X/*                                */
  40. X/****************************************************************/
  41. X/* This version of curses is based on ncurses, a curses version    */
  42. X/* originally written by Pavel Curtis at Cornell University.    */
  43. X/* I have made substantial changes to make it run on IBM PC's,    */
  44. X/* and therefore consider myself free make it public domain.    */
  45. X/*                Bjorn Larsson (bl@infovox.se)    */
  46. X/****************************************************************/
  47. X/* 1.4:  Portability improvements:            900114    */
  48. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  49. X/* 1.2:     Rcsid[] string for maintenance:        881002    */
  50. X/* 1.0:     Release:                    870515    */
  51. X/****************************************************************/
  52. X
  53. X#include <curses.h>
  54. X#include <curspriv.h>
  55. X
  56. Xchar _curses_attrib_rcsid[] = "@(#)attrib.c     v.1.4  - 900114";
  57. X
  58. X/****************************************************************/
  59. X/* Wattrset() sets the attributes as specified in window 'win'.    */
  60. X/****************************************************************/
  61. X
  62. Xvoid wattrset(win,attrs)
  63. X  WINDOW    *win;
  64. X  int         attrs;
  65. X  {
  66. X  win->_attrs = attrs & ATR_MSK;
  67. X  } /* wattrset */
  68. X
  69. X/****************************************************************/
  70. X/* Wattron() sets the specified attribute(s) in window 'win'.    */
  71. X/****************************************************************/
  72. X
  73. Xvoid    wattron(win,attrs)
  74. X  WINDOW    *win;
  75. X  int         attrs;
  76. X  {
  77. X  win->_attrs |= (attrs & ATR_MSK);
  78. X  } /* wattron */
  79. X
  80. X/****************************************************************/
  81. X/* Wattroff() clears the specified attribute(s) in window    */
  82. X/* 'win'.                            */
  83. X/****************************************************************/
  84. X
  85. Xvoid    wattroff(win,attrs)
  86. X  WINDOW    *win;
  87. X  int         attrs;
  88. X  {
  89. X  win->_attrs &= (~attrs & ATR_MSK);
  90. X  } /* wattroff */
  91. X
  92. X/****************************************************************/
  93. X/* Wstandout() starts standout mode in window 'win'.        */
  94. X/****************************************************************/
  95. X
  96. Xvoid    wstandout(win)
  97. X  WINDOW    *win;
  98. X  {
  99. X  win->_attrs = A_STANDOUT;
  100. X  } /* wstandout */
  101. X
  102. X/****************************************************************/
  103. X/* Wstandend() clears all special attributes in window 'win'.    */
  104. X/****************************************************************/
  105. X
  106. Xvoid    wstandend(win)
  107. X  WINDOW    *win;
  108. X  {
  109. X  win->_attrs = ATR_NRM;
  110. X  } /* wstandend */
  111. X
  112. X/****************************************************************/
  113. X/* Attrset() sets the attributes as specified in stdscr.    */
  114. X/****************************************************************/
  115. X
  116. Xvoid    attrset(attrs)
  117. X  int attrs;
  118. X  {
  119. X  stdscr->_attrs = attrs & ATR_MSK;
  120. X  } /* attrset */
  121. X
  122. X/****************************************************************/
  123. X/* Attron() sets the specified attribute(s) in stdscr.        */
  124. X/****************************************************************/
  125. X
  126. Xvoid    attron(attrs)
  127. X  int         attrs;
  128. X  {
  129. X  stdscr->_attrs |= (attrs & ATR_MSK);
  130. X  } /* attron */
  131. X
  132. X/****************************************************************/
  133. X/* Attroff() clears the specified attribute(s) in stdscr.    */
  134. X/****************************************************************/
  135. X
  136. Xvoid    attroff(attrs)
  137. X  int         attrs;
  138. X  {
  139. X  stdscr->_attrs &= (~attrs & ATR_MSK);
  140. X  } /* attroff */
  141. X
  142. X/****************************************************************/
  143. X/* Standout() starts standout mode in stdscr.            */
  144. X/****************************************************************/
  145. X
  146. Xvoid    standout()
  147. X  {
  148. X  stdscr->_attrs = A_STANDOUT;
  149. X  } /* standout */
  150. X
  151. X/****************************************************************/
  152. X/* Standend() clears all special attributes in stdscr.        */
  153. X/****************************************************************/
  154. X
  155. Xvoid    standend()
  156. X  {
  157. X  stdscr->_attrs = ATR_NRM;
  158. X  } /* standend */
  159. END_OF_attrib.c
  160. if test 3851 -ne `wc -c <attrib.c`; then
  161.     echo \"attrib.c\" unpacked with wrong size!
  162. fi
  163. # end of overwriting check
  164. fi
  165. if test -f border.c -a "${1}" != "-c" ; then 
  166.   echo Will not over-write existing file \"border.c\"
  167. else
  168. echo Extracting - \"border.c\"
  169. sed "s/^X//" >border.c <<'END_OF_border.c'
  170. X/****************************************************************/
  171. X/* Box border control routines of the PCcurses package.        */
  172. X/*                                */
  173. X/****************************************************************/
  174. X/* This version of curses is based on ncurses, a curses version    */
  175. X/* originally written by Pavel Curtis at Cornell University.    */
  176. X/* I have made substantial changes to make it run on IBM PC's,    */
  177. X/* and therefore consider myself free make it public domain.    */
  178. X/*                Bjorn Larsson (bl@infovox.se)    */
  179. X/****************************************************************/
  180. X/* 1.4 : Changed to draw a border. Use short wherever        */
  181. X/*     possible: Portability improvements:        900114    */
  182. X/* 1.3:     Released:                    881005    */
  183. X/****************************************************************/
  184. X
  185. X#include <curses.h>
  186. X#include <curspriv.h>
  187. X
  188. Xchar _curses_border_rcsid[] = "@(#)border.c     v.1.4  - 900114";
  189. X
  190. X/****************************************************************/
  191. X/* Wborder(win, l, r, t, b, tl, tr, bl, br) draws a border in    */
  192. X/* window win, with the specified characters as border edges:    */
  193. X/* l    left                            */
  194. X/* r    right                            */
  195. X/* b    bottom                            */
  196. X/* t    top                            */
  197. X/* tl    top left corner                        */
  198. X/* tr    top right corner                    */
  199. X/* bl    bottom left corner                    */
  200. X/* br    bottom right corner                    */
  201. X/****************************************************************/
  202. X
  203. Xvoid wborder(win, l, r, t, b, tl, tr, bl, br)
  204. X  WINDOW    *win;
  205. X  int         l;
  206. X  int         r;
  207. X  int         t;
  208. X  int         b;
  209. X  int         tl;
  210. X  int         tr;
  211. X  int         bl;
  212. X  int         br;
  213. X  {
  214. X  short     xmax, ymax, i;
  215. X
  216. X  ymax = win->_maxy - 1;
  217. X  xmax = win->_maxx - 1;
  218. X  for (i = 1; i <= xmax-1;i++)
  219. X    {
  220. X    win->_line[0][i] =     t | win->_attrs;
  221. X    win->_line[ymax][i] =  b | win->_attrs;
  222. X    } /* for */
  223. X  for (i = 1;i <= ymax-1;i++)
  224. X    {
  225. X    win->_line[i][0] =     l | win->_attrs;
  226. X    win->_line[i][xmax] =  r | win->_attrs;
  227. X    } /* for */
  228. X  win->_line[0][0] =       tl | win->_attrs;
  229. X  win->_line[0][xmax] =    tr | win->_attrs;
  230. X  win->_line[ymax][0] =    bl | win->_attrs;
  231. X  win->_line[ymax][xmax] = br | win->_attrs;
  232. X
  233. X  for (i=0; i <= ymax ; i++)
  234. X    {
  235. X    win->_minchng[i] = 0;
  236. X    win->_maxchng[i] = xmax;
  237. X    } /* for */
  238. X  } /* wborder */
  239. X
  240. X/****************************************************************/
  241. X/* Border(l, r, t, b, tl, tr, bl, br) draws a border in stdscr,    */
  242. X/* with the specified characters as border edges:        */
  243. X/* l    left                            */
  244. X/* r    right                            */
  245. X/* b    bottom                            */
  246. X/* t    top                            */
  247. X/* tl    top left corner                        */
  248. X/* tr    top right corner                    */
  249. X/* bl    bottom left corner                    */
  250. X/* br    bottom right corner                    */
  251. X/* Don't make this a call to wborder() - it would require soo    */
  252. X/* much stack for parameters...                    */
  253. X/****************************************************************/
  254. X
  255. Xvoid border(l, r, t, b, tl, tr, bl, br)
  256. X  int         l;
  257. X  int         r;
  258. X  int         t;
  259. X  int         b;
  260. X  int         tl;
  261. X  int         tr;
  262. X  int         bl;
  263. X  int         br;
  264. X  {
  265. X  short     xmax, ymax, i;
  266. X
  267. X  ymax = stdscr->_maxy - 1;
  268. X  xmax = stdscr->_maxx - 1;
  269. X  for (i = 1; i <= xmax-1;i++)
  270. X    {
  271. X    stdscr->_line[0][i] =     t | stdscr->_attrs;
  272. X    stdscr->_line[ymax][i] =  b | stdscr->_attrs;
  273. X    } /* for */
  274. X  for (i = 1;i <= ymax-1;i++)
  275. X    {
  276. X    stdscr->_line[i][0] =     l | stdscr->_attrs;
  277. X    stdscr->_line[i][xmax] =  r | stdscr->_attrs;
  278. X    } /* for */
  279. X  stdscr->_line[0][0] =       tl | stdscr->_attrs;
  280. X  stdscr->_line[0][xmax] =    tr | stdscr->_attrs;
  281. X  stdscr->_line[ymax][0] =    bl | stdscr->_attrs;
  282. X  stdscr->_line[ymax][xmax] = br | stdscr->_attrs;
  283. X
  284. X  for (i=0; i <= ymax ; i++)
  285. X    {
  286. X    stdscr->_minchng[i] = 0;
  287. X    stdscr->_maxchng[i] = xmax;
  288. X    } /* for */
  289. X  } /* border */
  290. END_OF_border.c
  291. if test 3600 -ne `wc -c <border.c`; then
  292.     echo \"border.c\" unpacked with wrong size!
  293. fi
  294. # end of overwriting check
  295. fi
  296. if test -f boxes.c -a "${1}" != "-c" ; then 
  297.   echo Will not over-write existing file \"boxes.c\"
  298. else
  299. echo Extracting - \"boxes.c\"
  300. sed "s/^X//" >boxes.c <<'END_OF_boxes.c'
  301. X/****************************************************************/
  302. X/* Box() routines of the PCcurses package            */
  303. X/*                                */
  304. X/****************************************************************/
  305. X/* This version of curses is based on ncurses, a curses version    */
  306. X/* originally written by Pavel Curtis at Cornell University.    */
  307. X/* I have made substantial changes to make it run on IBM PC's,    */
  308. X/* and therefore consider myself free to make it public domain.    */
  309. X/*                Bjorn Larsson (bl@infovox.se)    */
  310. X/****************************************************************/
  311. X/* 1.4:  References to win->borderchar[] removed due to        */
  312. X/*     re-defined border() functions. Use of short        */
  313. X/*     wherever possible. Portability improvements:    900114    */
  314. X/* 1.3:  MSC '-W3', Turbo'C' '-w -w-pro' checks.        */
  315. X/*     Support for border(), wborder() functions:    881005    */
  316. X/* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  317. X/* 1.0:     Release:                    870515    */
  318. X/****************************************************************/
  319. X
  320. X#include <curses.h>
  321. X#include <curspriv.h>
  322. X
  323. Xchar _curses_boxes_rcsid[] = "@(#)boxes.c      v.1.4  - 900114";
  324. X
  325. X/****************************************************************/
  326. X/* wbox(win,ymin,xmin,ymax,xmax,v,h) draws a box in window    */
  327. X/* 'win', enclosing the area xmin-xmax and ymin-xmax. If    */
  328. X/* xmax and/or ymax is 0, the window max value is used. 'v' and    */
  329. X/* 'h' are the vertical and horizontal characters to use. If    */
  330. X/* 'v' and 'h' are PC grapics lines, wbox will make the corners    */
  331. X/* in a pretty way.                        */
  332. X/****************************************************************/
  333. X
  334. Xint    wbox(win,ymin,xmin,ymax,xmax,v,h)
  335. X  WINDOW    *win;
  336. X  int         ymin;
  337. X  int         xmin;
  338. X  int         ymax;
  339. X  int         xmax;
  340. X  char         v;
  341. X  char         h;
  342. X  {
  343. X  static short     l, r, t, b, tl, tr, bl,br;    /* border chars */
  344. X  short         i;
  345. X
  346. X  if (ymax == 0)
  347. X    ymax = win->_maxy - 1;
  348. X  if (xmax == 0)
  349. X    xmax = win->_maxx - 1;
  350. X
  351. X  if (ymin >= win->_maxy || ymax > win->_maxy ||
  352. X      xmin >= win->_maxx || xmax > win->_maxx ||
  353. X      ymin >= ymax || xmin >= xmax
  354. X     )
  355. X     return(ERR);
  356. X
  357. X  l = r = v & 0xff;            /* get rid of sign-extended int */
  358. X  t = b = h & 0xff;
  359. X  tl = tr = bl = br = v;        /* default same as vertical */
  360. X
  361. X  if (l == 0xba)            /* vertical double bars */
  362. X    {
  363. X    if (t == 0xcd)            /* horizontal too? */
  364. X      {tl=0xc9;tr=0xbb;bl=0xc8;br=0xbc;}/* use double bar corners */
  365. X    else
  366. X      {tl=0xd6;tr=0xb7;bl=0xd3;br=0xbd;}/* use hor-s vert-d corners */
  367. X    } /* if */
  368. X
  369. X  if (l == 0xb3)            /* vertical single bars */
  370. X    {
  371. X    if (t == 0xcd)            
  372. X      {tl=0xd5;tr=0xb8;bl=0xd4;br=0xbe;}/* horizontal double bars */
  373. X    else                
  374. X      {tl=0xda;tr=0xbf;bl=0xc0;br=0xd9;}/* use hor-s vert-s bars */
  375. X    } /* if */
  376. X  for (i = xmin+1;i <= xmax-1;i++)
  377. X    {
  378. X    win->_line[ymin][i] = t | win->_attrs;
  379. X    win->_line[ymax][i] = b | win->_attrs;
  380. X    }
  381. X  for (i = ymin+1;i <= ymax-1;i++)
  382. X    {
  383. X    win->_line[i][xmin] = l | win->_attrs;
  384. X    win->_line[i][xmax] = r | win->_attrs;
  385. X    }
  386. X  win->_line[ymin][xmin] = tl | win->_attrs;
  387. X  win->_line[ymin][xmax] = tr | win->_attrs;
  388. X  win->_line[ymax][xmin] = bl | win->_attrs;
  389. X  win->_line[ymax][xmax] = br | win->_attrs;
  390. X
  391. X  for (i=ymin; i <= ymax ; i++)
  392. X    {
  393. X    if (win->_minchng[i] == _NO_CHANGE)
  394. X      {
  395. X      win->_minchng[i] = xmin;
  396. X      win->_maxchng[i] = xmax;
  397. X      } /* if */
  398. X    else
  399. X      {
  400. X      win->_minchng[i] = min(win->_minchng[i], xmin);
  401. X      win->_maxchng[i] = max(win->_maxchng[i], xmax);
  402. X      } /* else */
  403. X    } /* for */
  404. X  return(OK);
  405. X  } /* box */
  406. X
  407. X/****************************************************************/
  408. X/* box(win,v,h) draws a box around window window 'win'. 'v' and    */
  409. X/* 'h' are the vertical and horizontal characters to use.    */
  410. X/****************************************************************/
  411. X
  412. Xvoid    box(win,v,h)
  413. X  WINDOW    *win;
  414. X  char         v;
  415. X  char         h;
  416. X  {
  417. X  wbox(win,0,0,0,0,v,h);
  418. X  } /* box */
  419. END_OF_boxes.c
  420. if test 3864 -ne `wc -c <boxes.c`; then
  421.     echo \"boxes.c\" unpacked with wrong size!
  422. fi
  423. # end of overwriting check
  424. fi
  425. if test -f chardel.c -a "${1}" != "-c" ; then 
  426.   echo Will not over-write existing file \"chardel.c\"
  427. else
  428. echo Extracting - \"chardel.c\"
  429. sed "s/^X//" >chardel.c <<'END_OF_chardel.c'
  430. X/****************************************************************/
  431. X/* Wdelch() routine of the PCcurses package            */
  432. X/*                                */
  433. X/****************************************************************/
  434. X/* This version of curses is based on ncurses, a curses version    */
  435. X/* originally written by Pavel Curtis at Cornell University.    */
  436. X/* I have made substantial changes to make it run on IBM PC's,    */
  437. X/* and therefore consider myself free to make it public domain.    */
  438. X/*                Bjorn Larsson (bl@infovox.se)    */
  439. X/****************************************************************/
  440. X/* 1.4:  Use short wherever possible. Portability        */
  441. X/*     improvements:                    900114    */
  442. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  443. X/* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  444. X/* 1.0:     Release:                    870515    */
  445. X/****************************************************************/
  446. X
  447. X#include <curses.h>
  448. X#include <curspriv.h>
  449. X
  450. Xchar _curses_chardel_rcsid[] = "@(#)chardel.c    v.1.4  - 900114";
  451. X
  452. X/****************************************************************/
  453. X/* Wdelch() deletes the character at the window cursor, and the    */
  454. X/* characters to the right of it are shifted left, inserting a    */
  455. X/* space at the last position of the line.            */
  456. X/****************************************************************/
  457. X
  458. Xint    wdelch(win)
  459. X  WINDOW    *win;
  460. X  {
  461. X  short        *temp1;
  462. X  short        *temp2;
  463. X  short        *end;
  464. X  short     y = win->_cury;
  465. X  short     x = win->_curx;
  466. X  short     maxx = win->_maxx - 1;
  467. X
  468. X  end = &win->_line[y][maxx];
  469. X  temp1 = &win->_line[y][x];
  470. X  temp2 = temp1 + 1;
  471. X  while (temp1 < end)
  472. X    *temp1++ = *temp2++;
  473. X  *temp1 = ' ' | (win->_attrs & ATR_MSK);
  474. X  win->_maxchng[y] = maxx;
  475. X  if (win->_minchng[y] == _NO_CHANGE || win->_minchng[y] > x)
  476. X    win->_minchng[y] = x;
  477. X  return(OK);
  478. X  } /* wdelch */
  479. X
  480. X/****************************************************************/
  481. X/* Delch() deletes the character at the stdscr cursor, and the    */
  482. X/* characters to the right of it are shifted left, inserting a    */
  483. X/* space at the last position of the line.            */
  484. X/****************************************************************/
  485. X
  486. Xint delch()
  487. X  {
  488. X  return(wdelch(stdscr));
  489. X  } /* delch */
  490. X
  491. X/****************************************************************/
  492. X/* Mvdelch() moves the stdscr cursor to a new position, then    */
  493. X/* deletes the character at the stdscr cursor, and the charac-    */
  494. X/* ters to the right of it are shifted left, inserting a space    */
  495. X/* at the last position of the line.                */
  496. X/****************************************************************/
  497. X
  498. Xint mvdelch(y,x)
  499. X  int y;
  500. X  int x;
  501. X  {
  502. X  if (wmove(stdscr,y,x) == ERR)
  503. X    return(ERR);
  504. X  return(wdelch(stdscr));
  505. X  } /* mvdelch */
  506. X
  507. X/****************************************************************/
  508. X/* Mvwdelch() moves the cursor of window 'win' to a new posi-    */
  509. X/* tion, then deletes the character at the stdscr cursor, and    */
  510. X/* the characters to the right of it are shifted left, inser-    */
  511. X/* ting a space at the last position of the line.        */
  512. X/****************************************************************/
  513. X
  514. Xint mvwdelch(win,y,x)
  515. X  WINDOW *win;
  516. X  int y;
  517. X  int x;
  518. X  {
  519. X  if (wmove(win,y,x) == ERR)
  520. X    return(ERR);
  521. X  return(wdelch(win));
  522. X  } /* mvwdelch */
  523. END_OF_chardel.c
  524. if test 3197 -ne `wc -c <chardel.c`; then
  525.     echo \"chardel.c\" unpacked with wrong size!
  526. fi
  527. # end of overwriting check
  528. fi
  529. if test -f clrtobot.c -a "${1}" != "-c" ; then 
  530.   echo Will not over-write existing file \"clrtobot.c\"
  531. else
  532. echo Extracting - \"clrtobot.c\"
  533. sed "s/^X//" >clrtobot.c <<'END_OF_clrtobot.c'
  534. X/****************************************************************/
  535. X/* Wclrtobot() routine of the PCcurses package            */
  536. X/*                                */
  537. X/****************************************************************/
  538. X/* This version of curses is based on ncurses, a curses version    */
  539. X/* originally written by Pavel Curtis at Cornell University.    */
  540. X/* I have made substantial changes to make it run on IBM PC's,    */
  541. X/* and therefore consider myself free to make it public domain.    */
  542. X/*                Bjorn Larsson (bl@infovox.se)    */
  543. X/****************************************************************/
  544. X/* 1.4:  Use of short wherever possible. Portability        */
  545. X/*     improvements:                    900114    */
  546. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  547. X/* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  548. X/* 1.1:     Renamed clrbot() to clrtobot(). Reported by        */
  549. X/*     Eric Roscos:                    870907    */
  550. X/* 1.0:     Release:                    870515    */
  551. X/****************************************************************/
  552. X
  553. X#include <curses.h>
  554. X#include <curspriv.h>
  555. X
  556. Xchar _curses_clrtobot_rcsid[] = "@(#)clrtobot.c   v.1.4  - 900114";
  557. X
  558. X/****************************************************************/
  559. X/* Wclrtobot() fills the right half of the cursor line of    */
  560. X/* window 'win', and all lines below it with blanks.        */
  561. X/****************************************************************/
  562. X
  563. Xint    wclrtobot(win)
  564. X  WINDOW    *win;
  565. X  {
  566. X  short     y;
  567. X  short   minx;
  568. X  static short    startx;
  569. X  static short    *ptr;
  570. X  static short  *end;
  571. X  static short  *maxx;
  572. X  static short   blank;
  573. X
  574. X  blank = ' ' | (win->_attrs & ATR_MSK);
  575. X  startx = win->_curx;
  576. X  for (y = win->_cury; y <= win->_regbottom; y++)
  577. X    {
  578. X    minx = _NO_CHANGE;
  579. X    end = &win->_line[y][win->_maxx - 1];
  580. X    for (ptr = &win->_line[y][startx]; ptr <= end; ptr++)
  581. X      {
  582. X      if (*ptr != blank)
  583. X    {
  584. X    maxx = ptr;
  585. X    if (minx == _NO_CHANGE)
  586. X      minx = (int) (ptr - win->_line[y]);
  587. X    *ptr = blank;
  588. X    } /* if */
  589. X      } /* for */
  590. X    if (minx != _NO_CHANGE)
  591. X      {
  592. X      if ((win->_minchng[y] > minx) ||  (win->_minchng[y] == _NO_CHANGE))
  593. X    win->_minchng[y] = minx;
  594. X      if (win->_maxchng[y] < (int) (maxx - win->_line[y]))
  595. X    win->_maxchng[y] = (int) (maxx - win->_line[y]);
  596. X      } /* if */
  597. X    startx = 0;
  598. X    } /* for */
  599. X  return(OK);
  600. X  } /* wclrtobot */
  601. X
  602. X/****************************************************************/
  603. X/* Clrtobot() fills the right half of the cursor line of    */
  604. X/* stdscr, and all lines below it with blanks.            */
  605. X/****************************************************************/
  606. X
  607. Xint clrtobot()
  608. X  {
  609. X  return(wclrtobot(stdscr));
  610. X  } /* clrtobot */
  611. X
  612. X/****************************************************************/
  613. X/* Mvclrtobot() moves the cursor to a new position in stdscr    */
  614. X/* and fills the right half of the cursor line, and all lines    */
  615. X/* below it with blanks.                    */
  616. X/****************************************************************/
  617. X
  618. Xint mvclrtobot(y,x)
  619. X  int y;
  620. X  int x;
  621. X  {
  622. X  if (wmove(stdscr,y,x) == ERR)
  623. X    return(ERR);
  624. X  return(wclrtobot(stdscr));
  625. X  } /* mvclrtobot */
  626. X
  627. X/****************************************************************/
  628. X/* Mvwclrtobot() moves the cursor to a new position in window    */
  629. X/* 'win', and fills the right half of the cursor line, and all    */
  630. X/* lines below it with blanks.                    */
  631. X/****************************************************************/
  632. X
  633. Xint mvwclrtobot(win,y,x)
  634. X  WINDOW *win;
  635. X  int y;
  636. X  int x;
  637. X  {
  638. X  if (wmove(win,y,x) == ERR)
  639. X    return(ERR);
  640. X  return(wclrtobot(win));
  641. X  } /* mvwclrtobot */
  642. END_OF_clrtobot.c
  643. if test 3457 -ne `wc -c <clrtobot.c`; then
  644.     echo \"clrtobot.c\" unpacked with wrong size!
  645. fi
  646. # end of overwriting check
  647. fi
  648. if test -f clrtoeol.c -a "${1}" != "-c" ; then 
  649.   echo Will not over-write existing file \"clrtoeol.c\"
  650. else
  651. echo Extracting - \"clrtoeol.c\"
  652. sed "s/^X//" >clrtoeol.c <<'END_OF_clrtoeol.c'
  653. X/****************************************************************/
  654. X/* Wclrtoeol() routine of the PCcurses package            */
  655. X/*                                */
  656. X/****************************************************************/
  657. X/* This version of curses is based on ncurses, a curses version    */
  658. X/* originally written by Pavel Curtis at Cornell University.    */
  659. X/* I have made substantial changes to make it run on IBM PC's,    */
  660. X/* and therefore consider myself free to make it public domain.    */
  661. X/*                Bjorn Larsson (bl@infovox.se)    */
  662. X/****************************************************************/
  663. X/* 1.4:  Use of short wherever possible. Portability        */
  664. X/*     improvements, misspelled name of mvcrltoeol():    900114    */
  665. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  666. X/* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    880210    */
  667. X/* 1.0:     Release:                    870515    */
  668. X/****************************************************************/
  669. X
  670. X#include <curses.h>
  671. X#include <curspriv.h>
  672. X
  673. Xchar _curses_clrtoeol_rcsid[] = "@(#)clrtoeol.c   v.1.4  - 900114";
  674. X
  675. X/****************************************************************/
  676. X/* Wclrtoeol() fills the half of the cursor line to the right    */
  677. X/* of the cursor in window 'win' with blanks.            */
  678. X/****************************************************************/
  679. X
  680. Xint    wclrtoeol(win)
  681. X   WINDOW    *win;
  682. X  {
  683. X  short        *maxx;
  684. X  short        *ptr;
  685. X  short        *end;
  686. X  static short     y;
  687. X  static short     x;
  688. X  static short     minx;
  689. X  static short     blank;
  690. X  
  691. X  y = win->_cury;
  692. X  x = win->_curx;
  693. X  blank = ' ' | (win->_attrs & ATR_MSK);
  694. X
  695. X  end = &win->_line[y][win->_maxx - 1];
  696. X  minx = _NO_CHANGE;
  697. X  maxx = &win->_line[y][x];
  698. X  for (ptr = maxx; ptr <= end; ptr++)
  699. X    {
  700. X    if (*ptr != blank)
  701. X      {
  702. X      maxx = ptr;
  703. X      if (minx == _NO_CHANGE)
  704. X    minx = (int) (ptr - win->_line[y]);
  705. X      *ptr = blank;
  706. X      } /* if */
  707. X    } /* for */
  708. X
  709. X  if (minx != _NO_CHANGE)
  710. X    {
  711. X    if ((win->_minchng[y] > minx) || (win->_minchng[y] == _NO_CHANGE))
  712. X      win->_minchng[y] = minx;
  713. X    if (win->_maxchng[y] < (int) (maxx - win->_line[y]))
  714. X      win->_maxchng[y] = (int) (maxx - win->_line[y]);
  715. X    } /* if */
  716. X  return(OK);
  717. X  } /* wclrtoeol */
  718. X
  719. X/****************************************************************/
  720. X/* Clrtoeol() fills the half of the cursor line to the right    */
  721. X/* of the cursor in stdscr with blanks.                */
  722. X/****************************************************************/
  723. X
  724. Xint clrtoeol()
  725. X  {
  726. X  return(wclrtoeol(stdscr));
  727. X  } /* clrtoeol */
  728. X
  729. X/****************************************************************/
  730. X/* Mvclrtoeol() moves the cursor to a new position in stdscr    */
  731. X/* and fills the right half of the cursor line with blanks.    */
  732. X/****************************************************************/
  733. X
  734. Xint mvclrtoeol(y,x)
  735. X  int y;
  736. X  int x;
  737. X  {
  738. X  if (wmove(stdscr,y,x) == ERR)
  739. X    return(ERR);
  740. X  return(wclrtoeol(stdscr));
  741. X  } /* mvclrtoeol */
  742. X
  743. X/****************************************************************/
  744. X/* Mvwclrtoeol() moves the cursor to a new position in window    */
  745. X/* 'win', and fills the right half of the cursor line with    */
  746. X/* blanks.                            */
  747. X/****************************************************************/
  748. X
  749. Xint mvwclrtoeol(win,y,x)
  750. X  WINDOW *win;
  751. X  int y;
  752. X  int x;
  753. X  {
  754. X  if (wmove(win,y,x) == ERR)
  755. X    return(ERR);
  756. X  return(wclrtoeol(win));
  757. X  } /* mvwclrtoeol */
  758. END_OF_clrtoeol.c
  759. if test 3276 -ne `wc -c <clrtoeol.c`; then
  760.     echo \"clrtoeol.c\" unpacked with wrong size!
  761. fi
  762. # end of overwriting check
  763. fi
  764. if test -f curspriv.h -a "${1}" != "-c" ; then 
  765.   echo Will not over-write existing file \"curspriv.h\"
  766. else
  767. echo Extracting - \"curspriv.h\"
  768. sed "s/^X//" >curspriv.h <<'END_OF_curspriv.h'
  769. X/****************************************************************/
  770. X/*               CURSPRIV.H                */
  771. X/* Header file for definitions and declarations for the        */
  772. X/* PCcurses package. These definitions should not be gene-    */
  773. X/* rally accessible to programmers.                */
  774. X/****************************************************************/
  775. X/* This version of curses is based on ncurses, a curses version    */
  776. X/* originally written by Pavel Curtis at Cornell University.    */
  777. X/* I have made substantial changes to make it run on IBM PC's,    */
  778. X/* and therefore consider myself free to make it public domain.    */
  779. X/*                Bjorn Larsson (bl@infovox.se)    */
  780. X/****************************************************************/
  781. X/* 1.4:  ERR/ OK redefinied in curses.h. Use of short        */
  782. X/*     wherever possible Portability improvements:    900114    */
  783. X/* 1.3:     All modules lint-checked with MSC '-W3' and        */
  784. X/*     Turbo'C' '-w -w-pro' switches:            881005    */
  785. X/* 1.2:     Support (by #ifdef UCMASM) for uppercase-only        */
  786. X/*     assembly routine names. If UCMASM if defined,        */
  787. X/*     all assembler names are #defined as upper case.    */
  788. X/*     Not needed if you do "MASM /MX. Also missing        */
  789. X/*      declaration of cursesscroll(). Fixes thanks to        */
  790. X/*     N.D. Pentcheff:                881002    */ 
  791. X/* 1.1:     Add _chadd() for raw output routines:        880306    */
  792. X/* 1.0:     Release:                    870515    */
  793. X/****************************************************************/
  794. X
  795. X#define    CURSES_RCS_ID    "@(#)PCcurses     v.1.4  - 900114"
  796. X
  797. X/* window properties */
  798. X
  799. X#define    _SUBWIN        1        /* window is a subwindow */
  800. X#define    _ENDLINE    2        /* last winline is last screen line */
  801. X#define    _FULLWIN    4        /* window fills screen */
  802. X#define    _SCROLLWIN    8        /* window lwr rgt is screen lwr rgt */
  803. X
  804. X/* Miscellaneous */
  805. X
  806. X#define    _INBUFSIZ    200        /* size of terminal input buffer */
  807. X#define    _NO_CHANGE    -1        /* flags line edge unchanged */
  808. X
  809. X#define    _BREAKCHAR    0x03        /* ^C character */
  810. X#define _DCCHAR        0x08        /* Delete Char char (BS) */
  811. X#define _DLCHAR        0x1b        /* Delete Line char (ESC) */
  812. X#define    _GOCHAR        0x11        /* ^Q character */
  813. X#define    _PRINTCHAR    0x10        /* ^P character */
  814. X#define    _STOPCHAR    0x13        /* ^S character */
  815. X#define     NUNGETCH    10        /* max # chars to ungetch() */
  816. X
  817. X/* character mask definitions */
  818. X
  819. X#define CHR_MSK    ((int) 0x00ff)        /* ASCIIZ character mask */
  820. X#define    ATR_MSK    ((int) 0xff00)        /* attribute mask */
  821. X#define ATR_NRM    ((int) 0x0000)        /* no special attributes */
  822. X
  823. X/* type declarations */
  824. X
  825. Xtypedef    struct
  826. X  {
  827. X  WINDOW  *tmpwin;            /* window used for updates */
  828. X  short       cursrow;            /* position of physical cursor */
  829. X  short       curscol;
  830. X  bool       autocr;            /* if lf -> crlf */
  831. X  bool       cbreak;            /* if terminal unbuffered */
  832. X  bool       echo;            /* if terminal echo */
  833. X  bool       raw;                /* if terminal raw mode */
  834. X  bool       refrbrk;            /* if premature refresh brk allowed */
  835. X  bool     orgcbr;            /* original MSDOS ^-BREAK setting */
  836. X  }    cursv;
  837. X
  838. X/* External variables */
  839. X
  840. Xextern    cursv   _cursvar;        /* curses variables */
  841. X
  842. X/* 'C' standard library function declarations */
  843. X
  844. Xextern    char    *calloc();
  845. Xextern    char    *malloc();
  846. Xextern    void     free();
  847. Xextern    int     sprintf();
  848. Xextern    int     sscanf();
  849. X
  850. X/* Curses internal functions, not to be used by programmers */
  851. X
  852. X/* #Define UCMASM if your version of MASM does not support */
  853. X/*  the '/MX' switch, or if you use another assembler */
  854. X
  855. X#ifdef    UCMASM
  856. X#define    _cursescattr    _CURSESCATTR
  857. X#define    _cursescmode    _CURSESCMODE
  858. X#define    _cursescursor    _CURSESCURSOR
  859. X#define    _cursesgcb    _CURSESGCB
  860. X#define    _cursesgcmode    _CURSESGCMODE
  861. X#define    _cursesgcols    _CURSESGCOLS
  862. X#define    _curseskey    _CURSESKEY
  863. X#define    _cursesscroll    _CURSESSCROLL
  864. X#define    _curseskeytst    _CURSESKEYTST
  865. X#define    _cursesputc    _CURSESPUTC
  866. X#define    _cursesscb    _CURSESSCB
  867. X#endif
  868. Xextern    int    _chadd();
  869. Xextern    void    _cursescattr();
  870. Xextern    void    _cursescmode();
  871. Xextern    void    _cursescursor();
  872. Xextern    int    _cursesgcb();
  873. Xextern    int    _cursesgcmode();
  874. Xextern    int    _cursesgcols();
  875. Xextern    int    _curseskey();
  876. Xextern    bool    _curseskeytst();
  877. Xextern    void    _cursesscroll();
  878. Xextern    bool    _cursespendch();
  879. Xextern    void    _cursesputc();
  880. Xextern    void    _cursesscb();
  881. END_OF_curspriv.h
  882. if test 3995 -ne `wc -c <curspriv.h`; then
  883.     echo \"curspriv.h\" unpacked with wrong size!
  884. fi
  885. # end of overwriting check
  886. fi
  887. if test -f linedel.c -a "${1}" != "-c" ; then 
  888.   echo Will not over-write existing file \"linedel.c\"
  889. else
  890. echo Extracting - \"linedel.c\"
  891. sed "s/^X//" >linedel.c <<'END_OF_linedel.c'
  892. X/****************************************************************/
  893. X/* Wdeleteln() routine of the PCcurses package            */
  894. X/*                                */
  895. X/****************************************************************/
  896. X/* This version of curses is based on ncurses, a curses version    */
  897. X/* originally written by Pavel Curtis at Cornell University.    */
  898. X/* I have made substantial changes to make it run on IBM PC's,    */
  899. X/* and therefore consider myself free to make it public domain.    */
  900. X/*        Bjorn Larsson (...mcvax!enea!infovax!bl)    */
  901. X/****************************************************************/
  902. X/* 1.4:  Use of short wherever possible. Portability        */
  903. X/*     improvements:                    900114    */
  904. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  905. X/* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  906. X/* 1.0:     Release:                    870515    */
  907. X/****************************************************************/
  908. X
  909. X#include <curses.h>
  910. X#include <curspriv.h>
  911. X
  912. Xchar _curses_linedel_rcsid[] = "@(#)linedel.c    v.1.4  - 900114";
  913. X
  914. X/****************************************************************/
  915. X/* Wdeleteln() deletes the line at the window cursor, and the    */
  916. X/* lines below it are shifted up, inserting a blank line at    */
  917. X/* the bottom of the window.                    */
  918. X/****************************************************************/
  919. X
  920. Xint    wdeleteln(win)
  921. X  WINDOW    *win;
  922. X  {
  923. X  short        *end;
  924. X  short        *temp;
  925. X  short     y;
  926. X  static short     blank;
  927. X  
  928. X  blank = ' ' | (win->_attrs & ATR_MSK);
  929. X
  930. X  temp = win->_line[win->_cury];
  931. X  for (y = win->_cury; y < win->_regbottom; y++)
  932. X    {
  933. X    win->_line[y] = win->_line[y+1];
  934. X    win->_minchng[y] = 0;
  935. X    win->_maxchng[y] = win->_maxx - 1;
  936. X    }
  937. X  win->_minchng[y] = 0;
  938. X  win->_maxchng[y] = win->_maxx - 1;
  939. X  win->_line[win->_regbottom] = temp;
  940. X  for (end = &(temp[win->_maxx -1]); temp <= end;)
  941. X    *temp++ = blank;
  942. X  return(OK);
  943. X  } /* wdeleteln */
  944. X
  945. X/****************************************************************/
  946. X/* Deleteln() deletes the line at the stdscr cursor, and the    */
  947. X/* lines below it are shifted up, inserting a blank line at    */
  948. X/* the bottom of stdscr.                    */
  949. X/****************************************************************/
  950. X
  951. Xint deleteln()
  952. X  {
  953. X  return(wdeleteln(stdscr));
  954. X  } /* deleteln */
  955. X
  956. X/****************************************************************/
  957. X/* Mvdeleteln() moves the cursor to a new position in stdscr,    */
  958. X/* then deletes the line at the window cursor, and the lines    */
  959. X/* below it are shifted up, inserting a blank line at the bot-    */
  960. X/* tom of stdscr.                        */
  961. X/****************************************************************/
  962. X
  963. Xint mvdeleteln(y,x)
  964. X  int y;
  965. X  int x;
  966. X  {
  967. X  if (wmove(stdscr,y,x) == ERR)
  968. X    return(ERR);
  969. X  return(wdeleteln(stdscr));
  970. X  } /* mvdeleteln */
  971. X
  972. X/****************************************************************/
  973. X/* Mvwdeleteln() moves the cursor to a new position in a win-    */
  974. X/* dow, then deletes the line at the window cursor, and the    */
  975. X/* lines below it are shifted up, inserting a blank line at    */
  976. X/* the bottom of the window.                    */
  977. X/****************************************************************/
  978. X
  979. Xint mvwdeleteln(win,y,x)
  980. X  WINDOW *win;
  981. X  int y;
  982. X  int x;
  983. X  {
  984. X  if (wmove(win,y,x) == ERR)
  985. X    return(ERR);
  986. X  return(wdeleteln(win));
  987. X  } /* mvwdeleteln */
  988. END_OF_linedel.c
  989. if test 3229 -ne `wc -c <linedel.c`; then
  990.     echo \"linedel.c\" unpacked with wrong size!
  991. fi
  992. # end of overwriting check
  993. fi
  994. if test -f lineins.c -a "${1}" != "-c" ; then 
  995.   echo Will not over-write existing file \"lineins.c\"
  996. else
  997. echo Extracting - \"lineins.c\"
  998. sed "s/^X//" >lineins.c <<'END_OF_lineins.c'
  999. X/****************************************************************/
  1000. X/* Winsertln() routine of the PCcurses package            */
  1001. X/*                                */
  1002. X/****************************************************************/
  1003. X/* This version of curses is based on ncurses, a curses version    */
  1004. X/* originally written by Pavel Curtis at Cornell University.    */
  1005. X/* I have made substantial changes to make it run on IBM PC's,    */
  1006. X/* and therefore consider myself free to make it public domain.    */
  1007. X/*                Bjorn Larsson (bl@infovox.se)    */
  1008. X/****************************************************************/
  1009. X/* 1.4:  Use of short wherever possible. Portability        */
  1010. X/*     improvements:                    900114    */
  1011. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  1012. X/* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  1013. X/* 1.1:     Mvinsertln() and friends were misrenamed:    880305    */
  1014. X/* 1.0:     Release:                    870515    */
  1015. X/****************************************************************/
  1016. X
  1017. X#include <curses.h>
  1018. X#include <curspriv.h>
  1019. X
  1020. Xchar _curses_lineins_rcsid[] = "@(#)lineins.c    v.1.4  - 900114";
  1021. X
  1022. X/****************************************************************/
  1023. X/* Winsertln() inserts a blank line instead of the cursor line    */
  1024. X/* in window 'win' and pushes other lines down.            */
  1025. X/****************************************************************/
  1026. X
  1027. Xint    winsertln(win)
  1028. X  WINDOW    *win;
  1029. X  {
  1030. X  short        *temp;
  1031. X  short        *end;
  1032. X  short     y;
  1033. X  static short     blank;
  1034. X  
  1035. X  blank = ' ' | (win->_attrs & ATR_MSK);
  1036. X  temp = win->_line[win->_regbottom];
  1037. X  for (y = win->_regbottom;  y > win->_cury;  y--)
  1038. X    {
  1039. X    win->_line[y] = win->_line[y-1];
  1040. X    win->_minchng[y] = 0;
  1041. X    win->_maxchng[y] = win->_maxx - 1;
  1042. X    } /* for */
  1043. X  win->_line[win->_cury] = temp;
  1044. X  for (end = &temp[win->_maxx -1];  temp <= end;  temp++)
  1045. X    *temp = blank;
  1046. X  win->_minchng[win->_cury] = 0;
  1047. X  win->_maxchng[win->_cury] = win->_maxx - 1;
  1048. X  return(OK);
  1049. X  } /* winsertln */
  1050. X
  1051. X/****************************************************************/
  1052. X/* Insertln() inserts a blank line instead of the cursor line    */
  1053. X/* in stdscr and pushes other lines down.            */
  1054. X/****************************************************************/
  1055. X
  1056. Xint insertln()
  1057. X  {
  1058. X  return(winsertln(stdscr));
  1059. X  } /* insertln */
  1060. X
  1061. X/****************************************************************/
  1062. X/* Mvinsertln() moves the stdscr cursor to a new positions, in-    */
  1063. X/* serts a blank line instead of the cursor line and pushes    */
  1064. X/* other lines down.                        */
  1065. X/****************************************************************/
  1066. X
  1067. Xint mvinsertln(y,x)
  1068. X  int y;
  1069. X  int x;
  1070. X  {
  1071. X  if (wmove(stdscr,y,x) == ERR)
  1072. X    return(ERR);
  1073. X  return(winsertln(stdscr));
  1074. X  } /* mvinsertln */
  1075. X
  1076. X/****************************************************************/
  1077. X/* Mvwinsertln() moves the cursor in window 'win' to a new po-    */
  1078. X/* si tions, inserts a blank line instead of the cursor line    */
  1079. X/* and pushes other lines down.                    */
  1080. X/****************************************************************/
  1081. X
  1082. Xint mvwinsertln(win,y,x)
  1083. X  WINDOW *win;
  1084. X  int y;
  1085. X  int x;
  1086. X  {
  1087. X  if (wmove(win,y,x) == ERR)
  1088. X    return(ERR);
  1089. X  return(winsertln(win));
  1090. X  } /* mvwinsertln */
  1091. END_OF_lineins.c
  1092. if test 3103 -ne `wc -c <lineins.c`; then
  1093.     echo \"lineins.c\" unpacked with wrong size!
  1094. fi
  1095. # end of overwriting check
  1096. fi
  1097. if test -f options.c -a "${1}" != "-c" ; then 
  1098.   echo Will not over-write existing file \"options.c\"
  1099. else
  1100. echo Extracting - \"options.c\"
  1101. sed "s/^X//" >options.c <<'END_OF_options.c'
  1102. X/****************************************************************/
  1103. X/* Idlok(), clearok(), leaveok(), scrollok(), nodelay(), key-    */
  1104. X/* pad(), meta(), cursoff() and curson() routines of the    */
  1105. X/* PCcurses package.                        */
  1106. X/*                                */
  1107. X/****************************************************************/
  1108. X/* This version of curses is based on ncurses, a curses version    */
  1109. X/* originally written by Pavel Curtis at Cornell University.    */
  1110. X/* I have made substantial changes to make it run on IBM PC's,    */
  1111. X/* and therefore consider myself free to make it public domain.    */
  1112. X/*                Bjorn Larsson (bl@infovox.se)    */
  1113. X/****************************************************************/
  1114. X/* 1.4:  Use of short wherever possible. Portability        */
  1115. X/*     improvements:                    900114    */
  1116. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  1117. X/* 1.2:     Rcsid[] string for maintenance:        881002    */
  1118. X/* 1.0:     Release:                    870515    */
  1119. X/****************************************************************/
  1120. X
  1121. X#include <curses.h>
  1122. X#include <curspriv.h>
  1123. X
  1124. Xchar _curses_options_rcsid[] = "@(#)option.c     v.1.4  - 900114";
  1125. X
  1126. Xstatic bool    hasold = FALSE;        /* for remembering old cursor type */
  1127. Xstatic int    oldmode;
  1128. X
  1129. X/****************************************************************/
  1130. X/* Idlok() is used to set  flag for using the terminal insert/    */
  1131. X/* delete line capabilities. This is not relevant for the PC    */
  1132. X/* version of curses, and thus nothing is done.            */
  1133. X/****************************************************************/
  1134. X
  1135. Xvoid idlok()
  1136. X  {
  1137. X  } /* idlok */
  1138. X
  1139. X/****************************************************************/
  1140. X/* Clearok() marks window 'win' to cause screen clearing and    */
  1141. X/* redraw the next time a refresh is done.            */
  1142. X/****************************************************************/
  1143. X
  1144. Xvoid clearok(win, flag)
  1145. X  WINDOW    *win;
  1146. X  bool         flag;
  1147. X  {
  1148. X  if (win == curscr)
  1149. X    _cursvar.tmpwin->_clear = flag;
  1150. X  else
  1151. X    win->_clear = flag;
  1152. X  } /* clearok */
  1153. X
  1154. X/****************************************************************/
  1155. X/* Leaveok() marks window 'win' to allow the update routines    */
  1156. X/* to leave the hardware cursor where it happens to be at the    */
  1157. X/* end of update. Usually used in combination with cursoff().    */
  1158. X/****************************************************************/
  1159. X
  1160. Xvoid leaveok(win, flag)
  1161. X  WINDOW    *win;
  1162. X  bool         flag;
  1163. X  {
  1164. X  win->_leave = flag;
  1165. X  } /* leaveok */
  1166. X
  1167. X/****************************************************************/
  1168. X/* Scrollok() marks window 'win' to allow the scrolling region    */
  1169. X/* of it to actually scroll.                    */
  1170. X/****************************************************************/
  1171. X
  1172. Xvoid scrollok(win, flag)
  1173. X  WINDOW    *win;
  1174. X  bool         flag;
  1175. X  {
  1176. X  win->_scroll = flag;
  1177. X  } /* scrollok */
  1178. X
  1179. X/****************************************************************/
  1180. X/* Nodelay() marks the window to make character input non-    */
  1181. X/* waiting, i.e. if there is no character to get, -1 will be    */
  1182. X/* returned.                            */
  1183. X/****************************************************************/
  1184. X
  1185. Xvoid nodelay(win, flag)
  1186. X  WINDOW    *win;
  1187. X  bool         flag;
  1188. X  {
  1189. X  win->_nodelay = flag;
  1190. X  } /* nodelay */
  1191. X
  1192. X/****************************************************************/
  1193. X/* Keypad() marks window 'win' to use the special keypad mode.    */
  1194. X/****************************************************************/
  1195. X
  1196. Xvoid keypad(win, flag)
  1197. X  WINDOW    *win;
  1198. X  bool         flag;
  1199. X  {
  1200. X  win->_keypad = flag;
  1201. X  } /* keypad */
  1202. X
  1203. X/****************************************************************/
  1204. X/* Meta() allows use of any alternate character set allowed by    */
  1205. X/* the terminal. We always allow this on the PC, so this one    */
  1206. X/* does nothing.                        */
  1207. X/****************************************************************/
  1208. X
  1209. Xvoid meta()
  1210. X  {
  1211. X  } /* meta */
  1212. X
  1213. X/****************************************************************/
  1214. X/* Cursoff() turns off the hardware cursor.            */
  1215. X/****************************************************************/
  1216. X
  1217. Xvoid cursoff()
  1218. X  {
  1219. X  if (!hasold)
  1220. X    {
  1221. X    oldmode = _cursesgcmode();        /* get old cursor type */
  1222. X    hasold = TRUE;
  1223. X    }
  1224. X  _cursescmode(31,30);            /* turn it off */
  1225. X  } /* cursoff */
  1226. X
  1227. X/****************************************************************/
  1228. X/* Curson() turns on the hardware cursor.            */
  1229. X/****************************************************************/
  1230. X
  1231. Xvoid curson()
  1232. X  {
  1233. X  if (hasold)
  1234. X    {
  1235. X    _cursescmode(oldmode >> 8,oldmode);
  1236. X    hasold = FALSE;
  1237. X    }
  1238. X  } /* curson */
  1239. END_OF_options.c
  1240. if test 4376 -ne `wc -c <options.c`; then
  1241.     echo \"options.c\" unpacked with wrong size!
  1242. fi
  1243. # end of overwriting check
  1244. fi
  1245. if test -f refresh.c -a "${1}" != "-c" ; then 
  1246.   echo Will not over-write existing file \"refresh.c\"
  1247. else
  1248. echo Extracting - \"refresh.c\"
  1249. sed "s/^X//" >refresh.c <<'END_OF_refresh.c'
  1250. X/****************************************************************/
  1251. X/* Wrefresh() and wnoutrefresh() routines of the PCcurses    */
  1252. X/* package                            */
  1253. X/*                                */
  1254. X/****************************************************************/
  1255. X/* This version of curses is based on ncurses, a curses version    */
  1256. X/* originally written by Pavel Curtis at Cornell University.    */
  1257. X/* I have made substantial changes to make it run on IBM PC's,    */
  1258. X/* and therefore consider myself free to make it public domain.    */
  1259. X/*                Bjorn Larsson (bl@infovox.se)    */
  1260. X/****************************************************************/
  1261. X/* 1.4:  Use of short wherever possible. Refresh() slig-    */
  1262. X/*     htly faster. Portability improvements:        900114    */
  1263. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  1264. X/* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  1265. X/* 1.0:     Release:                    870515    */
  1266. X/****************************************************************/
  1267. X
  1268. X#include <curses.h>
  1269. X#include <curspriv.h>
  1270. X
  1271. Xchar _curses_refresh_rcsid[] = "@(#)refresh.c    v.1.4  - 900114";
  1272. X
  1273. X/****************************************************************/
  1274. X/* Wrefresh() updates window win's area of the physical screen.    */
  1275. X/****************************************************************/
  1276. X
  1277. Xvoid wrefresh(win)
  1278. X  WINDOW    *win;
  1279. X  {
  1280. X  if (win == curscr)
  1281. X    curscr->_clear = TRUE;
  1282. X  else
  1283. X    wnoutrefresh(win);
  1284. X  doupdate();
  1285. X  } /* wrefresh */
  1286. X
  1287. X/****************************************************************/
  1288. X/* Wnoutrefresh() updates the image of the desired screen,    */
  1289. X/* without doing physical update (copies window win's image to    */
  1290. X/* the _cursvar.tmpwin window, which is hidden from the user).    */
  1291. X/****************************************************************/
  1292. X
  1293. Xvoid wnoutrefresh(win)
  1294. X  register WINDOW    *win;
  1295. X  {
  1296. X  register short  *dst;            /* start destination in temp window */
  1297. X  register short  *end;            /* end destination in temp window */
  1298. X  register short  *src;            /* source in user window */
  1299. X  register short   first;        /* first changed char on line */
  1300. X  register short   last;        /* last changed char on line */
  1301. X  static   WINDOW *nscr;
  1302. X  static   short   begy;        /* window's place on screen */
  1303. X  static   short   begx;
  1304. X  static   short   i;
  1305. X  static   short   j;
  1306. X
  1307. X  nscr = _cursvar.tmpwin;
  1308. X  begy = win->_begy;
  1309. X  begx = win->_begx;
  1310. X
  1311. X  for (i=0, j=begy; i < win->_maxy; i++, j++)
  1312. X    {
  1313. X    if (win->_minchng[i] != _NO_CHANGE)
  1314. X      {
  1315. X      first = win->_minchng[i];
  1316. X      last  = win->_maxchng[i];
  1317. X      dst   = &(nscr->_line[j][begx + first]);
  1318. X      end   = &(nscr->_line[j][begx + last]);
  1319. X      src   = &(win->_line[i][first]);
  1320. X
  1321. X      while (dst <= end)         /* copy user line to temp window */
  1322. X    *dst++ = *src++;
  1323. X
  1324. X      first += begx;            /* nscr's min/max change positions */
  1325. X      last  += begx;
  1326. X
  1327. X      if ((nscr->_minchng[j] == _NO_CHANGE)||(nscr->_minchng[j] > first))
  1328. X    nscr->_minchng[j] = first;
  1329. X      if (last > nscr->_maxchng[j])
  1330. X    nscr->_maxchng[j] = last;
  1331. X      
  1332. X      win->_minchng[i] = _NO_CHANGE;    /* updated now */
  1333. X      } /* if */
  1334. X    win->_maxchng[i] = _NO_CHANGE;    /* updated now */
  1335. X    } /* for */
  1336. X
  1337. X  if (win->_clear)
  1338. X    {
  1339. X    win->_clear = FALSE;
  1340. X    nscr->_clear = TRUE;
  1341. X    } /* if */
  1342. X
  1343. X  if (!win->_leave)
  1344. X    {
  1345. X    nscr->_cury = win->_cury + begy;
  1346. X    nscr->_curx = win->_curx + begx;
  1347. X    } /* if */
  1348. X  } /* wnoutrefresh */
  1349. X
  1350. X/****************************************************************/
  1351. X/* Refresh() updates stdscr's area of the physical screen.    */
  1352. X/****************************************************************/
  1353. X
  1354. Xvoid refresh()
  1355. X  {
  1356. X  wnoutrefresh(stdscr);
  1357. X  doupdate();
  1358. X  } /* refresh */
  1359. END_OF_refresh.c
  1360. if test 3577 -ne `wc -c <refresh.c`; then
  1361.     echo \"refresh.c\" unpacked with wrong size!
  1362. fi
  1363. # end of overwriting check
  1364. fi
  1365. if test -f setmode.c -a "${1}" != "-c" ; then 
  1366.   echo Will not over-write existing file \"setmode.c\"
  1367. else
  1368. echo Extracting - \"setmode.c\"
  1369. sed "s/^X//" >setmode.c <<'END_OF_setmode.c'
  1370. X/****************************************************************/
  1371. X/* Terminal mode routines of the PCcurses package.        */
  1372. X/*                                */
  1373. X/****************************************************************/
  1374. X/* This version of curses is based on ncurses, a curses version    */
  1375. X/* originally written by Pavel Curtis at Cornell University.    */
  1376. X/* I have made substantial changes to make it run on IBM PC's,    */
  1377. X/* and therefore consider myself free make it public domain.    */
  1378. X/*                Bjorn Larsson (bl@infovox.se)    */
  1379. X/****************************************************************/
  1380. X/* BUT: this particualr module was written by            */
  1381. X/*    N. Dean Pentcheff  (dean@violet.berkeley.edu)        */
  1382. X/* It provides PC Curses versions of:                */
  1383. X/*    reset_prog_mode();                    */
  1384. X/*    reset_shell_mode();                    */
  1385. X/*    set_prog_mode();                    */
  1386. X/*    set_shell_mode();                    */
  1387. X/*                                */
  1388. X/* B. Larsson took the liberty to mofify it's style slightly    */
  1389. X/* when incorporating it into PCcurses v.1.2. The routines in    */
  1390. X/* this module do a similar thing to savetty() and resetty().    */
  1391. X/****************************************************************/
  1392. X/* 1.4:  Use of short wherever possible. Portability        */
  1393. X/*     improvements:                    900114    */
  1394. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  1395. X/* 1.2:     Style clean-up, rcsid[] string for main-        */
  1396. X/*     tenance:                    881002    */
  1397. X/****************************************************************/
  1398. X
  1399. X#include <curses.h>
  1400. X#include <curspriv.h>
  1401. X
  1402. Xstruct cttyset
  1403. X  {
  1404. X  bool    been_set;
  1405. X  bool    oautocr;
  1406. X  bool    ocbreak;
  1407. X  bool    oecho;
  1408. X  bool    oraw;
  1409. X  };
  1410. X    
  1411. Xchar _curses_setmode_rcsid[] = "@(#)setmode.c    v.1.4  - 900114";
  1412. X
  1413. Xstatic    struct cttyset pr_tty = {FALSE};/* tty modes for prog_mode  */
  1414. X
  1415. X/****************************************************************/
  1416. X/* Def_prog_mode() saves the current tty status, to be recalled    */
  1417. X/* later by reset_prog_mode.                    */
  1418. X/****************************************************************/
  1419. X
  1420. Xvoid def_prog_mode()
  1421. X  {
  1422. X  pr_tty.been_set = TRUE;
  1423. X  pr_tty.oautocr = _cursvar.autocr;
  1424. X  pr_tty.ocbreak = _cursvar.cbreak;
  1425. X  pr_tty.oecho    = _cursvar.echo;
  1426. X  pr_tty.oraw    = _cursvar.raw;
  1427. X  } /* def_prog_mode */
  1428. X
  1429. X/****************************************************************/
  1430. X/* Reset_prog_mode() resets tty modes to the values saved in a    */
  1431. X/* call to def_prog_mode.                    */
  1432. X/****************************************************************/
  1433. X
  1434. Xvoid reset_prog_mode()
  1435. X  {
  1436. X  if (pr_tty.been_set == TRUE)
  1437. X    {
  1438. X    _cursvar.autocr    = pr_tty.oautocr;
  1439. X    _cursvar.cbreak    = pr_tty.ocbreak;
  1440. X    _cursvar.echo    = pr_tty.oecho;
  1441. X    _cursvar.raw    = pr_tty.oraw;
  1442. X    } /* if */
  1443. X  } /* reset_prog_mode */
  1444. X
  1445. X/****************************************************************/
  1446. X/* Def_shell_mode() saves the tty status, to be recalled by    */
  1447. X/* reset_shell_mode. A noop in PCcurses.            */
  1448. X/****************************************************************/
  1449. X
  1450. Xvoid def_shell_mode()
  1451. X  {
  1452. X  } /* def_shell_mode */
  1453. X
  1454. X/****************************************************************/
  1455. X/* Reset_shell_mode() resets the tty status to the status it    */
  1456. X/* had before curses began.                    */
  1457. X/****************************************************************/
  1458. X
  1459. Xvoid reset_shell_mode()
  1460. X  {
  1461. X  _cursvar.autocr    = TRUE;
  1462. X  _cursvar.cbreak    = FALSE;
  1463. X  _cursvar.echo    = TRUE;
  1464. X  _cursvar.raw    = FALSE;
  1465. X  } /* reset_shell_mode */
  1466. END_OF_setmode.c
  1467. if test 3300 -ne `wc -c <setmode.c`; then
  1468.     echo \"setmode.c\" unpacked with wrong size!
  1469. fi
  1470. # end of overwriting check
  1471. fi
  1472. if test -f setterm.c -a "${1}" != "-c" ; then 
  1473.   echo Will not over-write existing file \"setterm.c\"
  1474. else
  1475. echo Extracting - \"setterm.c\"
  1476. sed "s/^X//" >setterm.c <<'END_OF_setterm.c'
  1477. X/****************************************************************/
  1478. X/* Raw(), noraw(), echo(), noecho(), nl(), nonl(),  cbreak(),    */
  1479. X/* nocbreak(), crmode(), nocrmode() and refrbrk() routines of    */
  1480. X/* the PCcurses package.                    */
  1481. X/*                                */
  1482. X/****************************************************************/
  1483. X/* This version of curses is based on ncurses, a curses version    */
  1484. X/* originally written by Pavel Curtis at Cornell University.    */
  1485. X/* I have made substantial changes to make it run on IBM PC's,    */
  1486. X/* and therefore consider myself free to make it public domain.    */
  1487. X/*                Bjorn Larsson (bl@infovox.se)    */
  1488. X/****************************************************************/
  1489. X/* 1.4:  Use of short wherever possible. Portability        */
  1490. X/*     improvements:                    900114    */
  1491. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  1492. X/* 1.2:     Rcsid[] string for maintenance:        881002    */
  1493. X/* 1.0:     Release:                    870515    */
  1494. X/****************************************************************/
  1495. X
  1496. X#include <curses.h>
  1497. X#include <curspriv.h>
  1498. X
  1499. Xchar _curses_setterm_rcsid[] = "@(#)setterm.c    v.1.4  - 900114";
  1500. X
  1501. X/****************************************************************/
  1502. X/* Raw() and noraw() sets or clears raw mode.            */
  1503. X/****************************************************************/
  1504. X
  1505. Xvoid  raw()
  1506. X  {
  1507. X  _cursvar.raw = TRUE;
  1508. X  _cursesscb(FALSE);            /* disallow ^BREAK on disk I/O */
  1509. X  flushinp();
  1510. X  } /* raw */
  1511. X
  1512. Xvoid  noraw()
  1513. X  {
  1514. X  _cursvar.raw = FALSE;
  1515. X  _cursesscb(_cursvar.orgcbr);        /* restore original ^BREAK status */
  1516. X  } /* noraw */
  1517. X
  1518. X/****************************************************************/
  1519. X/* Echo() and noecho() sets or clears echo mode.        */
  1520. X/****************************************************************/
  1521. X
  1522. Xvoid  echo()
  1523. X  {
  1524. X  _cursvar.echo = TRUE;
  1525. X  } /* echo */
  1526. X
  1527. Xvoid  noecho()
  1528. X  {
  1529. X  _cursvar.echo = FALSE;
  1530. X  } /* noecho */
  1531. X
  1532. X/****************************************************************/
  1533. X/* Nl() and nonl() sets or clears autocr mapping mode.        */
  1534. X/****************************************************************/
  1535. X
  1536. Xvoid  nl()
  1537. X  {
  1538. X  _cursvar.autocr = TRUE;
  1539. X  } /* nl */
  1540. X
  1541. Xvoid  nonl()
  1542. X  {
  1543. X  _cursvar.autocr = FALSE;
  1544. X  } /* nonl */
  1545. X
  1546. X/****************************************************************/
  1547. X/* Cbreak(), nocbreak(), crmode() amd nocrmode()  sets or    */
  1548. X/* clears cbreak mode.                        */
  1549. X/****************************************************************/
  1550. X
  1551. Xvoid  cbreak()
  1552. X  {
  1553. X  _cursvar.cbreak = TRUE;
  1554. X  } /* cbreak */
  1555. X
  1556. Xvoid  nocbreak()
  1557. X  {
  1558. X  _cursvar.cbreak = FALSE;
  1559. X  } /* nocbreak */
  1560. X
  1561. Xvoid  crmode()
  1562. X  {
  1563. X  _cursvar.cbreak = TRUE;
  1564. X  } /* crmode */
  1565. X
  1566. Xvoid  nocrmode()
  1567. X  {
  1568. X  _cursvar.cbreak = FALSE;
  1569. X  } /* nocrmode */
  1570. X
  1571. X/****************************************************************/
  1572. X/* Refrbrk() sets or unsets the screen refresh break flag. If    */
  1573. X/* this flag is set, and there is any input available, any    */
  1574. X/* screen refresh will be prematurely terminated, anticipating    */
  1575. X/* more screen updates. This flag is FALSE by default.        */
  1576. X/****************************************************************/
  1577. X
  1578. Xvoid    refrbrk(bf)
  1579. X  bool    bf;
  1580. X  {
  1581. X  _cursvar.refrbrk = bf;
  1582. X  } /* refrbrk */
  1583. END_OF_setterm.c
  1584. if test 3094 -ne `wc -c <setterm.c`; then
  1585.     echo \"setterm.c\" unpacked with wrong size!
  1586. fi
  1587. # end of overwriting check
  1588. fi
  1589. echo End of archive 2 \(of 7\).
  1590. cp /dev/null archdone.2
  1591. MISSING=""
  1592. for I in 1 2 3 4 5 6 7 ; do
  1593.     if test ! -f archdone.${I} ; then
  1594.     MISSING="${MISSING} ${I}"
  1595.     fi
  1596. done
  1597. if test "${MISSING}" = "" ; then
  1598.     echo You have unpacked all 7 archives.
  1599.     rm -f archdone.[1-9]
  1600. else
  1601.     echo You still need to unpack the following archives:
  1602.     echo "        " ${MISSING}
  1603. fi
  1604. ##  End of shell archive.
  1605. exit 0
  1606.  
  1607.